/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * LocalFileChooser.java
 *
 * Created on Dec 15, 2008, 5:24:47 PM
 */

package org.robcash.apps.messagepopup.view.components;

import org.robcash.commons.swing.wizard.WizardComponent;
import java.io.File;
import javax.swing.JFileChooser;

/**
 *
 * @author Rob
 */
public class LocalFileChooser extends WizardComponent {

    /** Creates new form LocalFileChooser */
    public LocalFileChooser() {
        initComponents();
    }

    /**
     * Get the selected file
     * @return File chosen using file chooser
     */
    public File getSelectedFile() {
        return fileChooser.getSelectedFile();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        fileChooser = new javax.swing.JFileChooser();
        instructions = new javax.swing.JLabel();

        setName("Form"); // NOI18N

        fileChooser.setControlButtonsAreShown(false);
        fileChooser.setFileFilter(new SubscriptionFileFilter());
        fileChooser.setFileSelectionMode(javax.swing.JFileChooser.FILES_AND_DIRECTORIES);
        fileChooser.setName("fileChooser"); // NOI18N
        fileChooser.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                fileChooserPropertyChange(evt);
            }
        });

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(org.robcash.apps.messagepopup.Main.class).getContext().getResourceMap(LocalFileChooser.class);
        instructions.setText(resourceMap.getString("instructions.text")); // NOI18N
        instructions.setName("instructions"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(instructions)
                .addContainerGap(391, Short.MAX_VALUE))
            .addComponent(fileChooser, javax.swing.GroupLayout.DEFAULT_SIZE, 602, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(instructions)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(fileChooser, javax.swing.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void fileChooserPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_fileChooserPropertyChange
        if ( JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(
                evt.getPropertyName()) ) {
            // User selected something
            fireChangeListenerStateChanged();
        }
    }//GEN-LAST:event_fileChooserPropertyChange


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JFileChooser fileChooser;
    private javax.swing.JLabel instructions;
    // End of variables declaration//GEN-END:variables

}
